package com.orangelife.mobile.individual.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.curry.android.util.DecimalUtil;
import com.curry.orangelife.mobile.R;
import com.orangelife.mobile.util.DateUtil;
import com.thirdlib.test.TestAdapter;

import java.util.List;
import java.util.Map;

public class BalanceDetailAdapter<T> extends TestAdapter<T> {

	private Context context;
	public BalanceDetailAdapter(Context context, int mResource,
			List<Map<String, Object>> list) {
		super(context, mResource, list);
		this.context=context;
	}

	@Override
	public void bindView(View view, int position, List<Map<String, Object>> list) {
		super.bindView(view, position, list);
		int operation = Integer.parseInt(list.get(position).get("operation").toString());
		String money = list.get(position).get("money").toString();
		String remark = list.get(position).get("remark").toString();
		Long time = Long.parseLong(list.get(position).get("tscreate").toString());
		TextView tvMoney = (TextView)view.findViewById(R.id.tvBalancePrice);
		TextView tvTime = (TextView)view.findViewById(R.id.tvBalanceTime);
		TextView tvTitle = (TextView)view.findViewById(R.id.tvBalanceTitle);
		switch (operation) {
		case 0:
			tvMoney.setText("+"+ DecimalUtil.decimalFormat(money));
			tvMoney.setTextColor(context.getResources().getColor(R.color.lightOrange));
			break;
		case 1:
			tvMoney.setText("-"+DecimalUtil.decimalFormat(money));
			tvMoney.setTextColor(context.getResources().getColor(R.color.text_black));
			break;
		case 2:
			tvMoney.setText("-"+DecimalUtil.decimalFormat(money));
			tvMoney.setTextColor(context.getResources().getColor(R.color.text_black));
			break;
		case 3:
			tvMoney.setText("+"+DecimalUtil.decimalFormat(money));
			tvMoney.setTextColor(context.getResources().getColor(R.color.lightOrange));
			break;
		case 4:
			tvMoney.setText("-"+DecimalUtil.decimalFormat(money));
			tvMoney.setTextColor(context.getResources().getColor(R.color.text_black));
			break;
		case 5:
			 tvMoney.setText("-"+DecimalUtil.decimalFormat(money));
			 tvMoney.setTextColor(context.getResources().getColor(R.color.text_black));
		default:
			break;
		}
		tvTime.setText(DateUtil.getInstance().tranLongForDate(time, "yyyy-MM-dd HH:mm"));
		tvTitle.setText(remark);
	}
}
